home *** CD-ROM | disk | FTP | other *** search
- Path: tank.news.pipex.net!pipex!demon!zace.compulink.co.uk
- From: chris@zace.compulink.co.uk (Chris)
- Newsgroups: comp.lang.c++
- Subject: Help on this C++ v1 program
- Date: Sat, 03 Feb 1996 18:51:35 GMT
- Message-ID: <31126397.2406958@PUBNEWS.DEMON.CO.UK>
- NNTP-Posting-Host: zace.compulink.co.uk
- X-NNTP-Posting-Host: zace.compulink.co.uk
- X-Newsreader: Forte Agent .99c/16.141
-
- Can anyone spot the problem that I am getting, and tell me where and
- why I am going wrong.
-
- The idea of this program is to put a line number at the start of each
- line of your files. (For those of you that have read it, yes, this
- code comes from Learn C in 21 days!)
- -----------------------------------------------------------------------------------------------------------
-
- #include <stdio.h>
- #include <process.h>
-
- void do_heading(char *filename);
-
- int line, page;
-
- main( int argv, char *argc[] )
- {
- char buffer[256];
- FILE *fp;
-
- if( argv <2)
- {
- fprintf(stderr, "\nProper Usage is : " );
- fprintf(stderr, "\n\nPRINT_IT filename.ext\n" );
- exit(1);
- }
-
- if (( fp = fopen( argc[1], "r" )) == NULL )
- {
- fprintf(stderr, "Error opening file, %s!", argc[1]);
- exit(1);
- }
-
- page = 0;
- line = 1;
- do_heading( argc[1]);
-
- while( fgets( buffer, 256, fp ) !=NULL )
- {
- if( line % 55 == 0)
- do_heading( argc[1] );
- fprintf(_stdprn, "%4d:\t%s", line++, buffer );
- }
-
- fprintf(_stdprn, "\f" );
- fclose(fp);
- return 0;
-
- }
-
- void do_heading( char *filename)
- {
- page++;
- if (page >1)
- fprintf(_stdprn,"\f");
- fprintf(_stdprn, "Page: %d, %s\n\n", page, filename);
- }
-
-
-